/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package edu.upn.sigemfi.plt.converter;

import edu.upn.sigemfi.plt.be.ParentescoVinculado;
import edu.upn.sigemfi.plt.bc.VinculadoDelegate;
import edu.upn.sigemfi.plt.bc.SucursalDelegate;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.ConverterException;

/**
 *
 * @author Administrador
 */
public class ParentescoConverter implements Converter {

    public Object getAsObject(FacesContext arg0, UIComponent arg1, String string) throws ConverterException {
        VinculadoDelegate delegado = new VinculadoDelegate();
        if (string == null) {
            return null;
        }
        try {//HAY QUE HACER EL CONVERTER
            Long codigo = Long.parseLong(string);
            if (codigo != null) {
                return delegado.buscar(codigo);
            } else {
                return null;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    public String getAsString(FacesContext arg0, UIComponent arg1, Object arg2) throws ConverterException {
        throw new UnsupportedOperationException("Not supported yet.");
    }

}
